package model.Entity.SIS;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;


/**
 * The persistent class for the SIS_STUDY_TYPES database table.
 * 
 */
@Entity
@Table(name="SIS_STUDY_TYPES")
@NamedQuery(name="StudyType.findAll", query="SELECT s FROM StudyType s")
public class StudyType implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@Column(name="STUDY_CODE")
	private Integer studyCode;

	@Temporal(TemporalType.DATE)
	@Column(name="ENTRY_DATE")
	private Date entryDate;

	@Column(name="ENTRY_USER")
	private Integer entryUser;

	@Column(name="FROM_TIME")
	private Integer fromTime;

	@Column(name="IS_REGULAR")
	private Integer isRegular;

	@Column(name="IS_RESTRICTIVE")
	private Integer isRestrictive;

	@Column(name="IS_STUDY_TYPE_FOLLOW")
	private Integer isStudyTypeFollow;

	@Column(name="MOHE_STUDY_CODE")
	private Integer moheStudyCode;

	@Column(name="OS_USER")
	private String osUser;

	@Column(name="STUDY_DESC")
	private String studyDesc;

	@Column(name="STUDY_DESC_S")
	private String studyDescS;

	private String terminal;

	//bi-directional many-to-one association to AcademicCalendar
	@OneToMany(mappedBy="studyType")
	private List<AcademicCalendar> academicCalendars;

	public StudyType() {
	}

	public Integer getStudyCode() {
		return this.studyCode;
	}

	public void setStudyCode(Integer studyCode) {
		this.studyCode = studyCode;
	}

	public Date getEntryDate() {
		return this.entryDate;
	}

	public void setEntryDate(Date entryDate) {
		this.entryDate = entryDate;
	}

	public Integer getEntryUser() {
		return this.entryUser;
	}

	public void setEntryUser(Integer entryUser) {
		this.entryUser = entryUser;
	}

	public Integer getFromTime() {
		return this.fromTime;
	}

	public void setFromTime(Integer fromTime) {
		this.fromTime = fromTime;
	}

	public Integer getIsRegular() {
		return this.isRegular;
	}

	public void setIsRegular(Integer isRegular) {
		this.isRegular = isRegular;
	}

	public Integer getIsRestrictive() {
		return this.isRestrictive;
	}

	public void setIsRestrictive(Integer isRestrictive) {
		this.isRestrictive = isRestrictive;
	}

	public Integer getIsStudyTypeFollow() {
		return this.isStudyTypeFollow;
	}

	public void setIsStudyTypeFollow(Integer isStudyTypeFollow) {
		this.isStudyTypeFollow = isStudyTypeFollow;
	}

	public Integer getMoheStudyCode() {
		return this.moheStudyCode;
	}

	public void setMoheStudyCode(Integer moheStudyCode) {
		this.moheStudyCode = moheStudyCode;
	}

	public String getOsUser() {
		return this.osUser;
	}

	public void setOsUser(String osUser) {
		this.osUser = osUser;
	}

	public String getStudyDesc() {
		return this.studyDesc;
	}

	public void setStudyDesc(String studyDesc) {
		this.studyDesc = studyDesc;
	}

	public String getStudyDescS() {
		return this.studyDescS;
	}

	public void setStudyDescS(String studyDescS) {
		this.studyDescS = studyDescS;
	}

	public String getTerminal() {
		return this.terminal;
	}

	public void setTerminal(String terminal) {
		this.terminal = terminal;
	}

	public List<AcademicCalendar> getAcademicCalendars() {
		return this.academicCalendars;
	}

	public void setAcademicCalendars(List<AcademicCalendar> academicCalendars) {
		this.academicCalendars = academicCalendars;
	}

	public AcademicCalendar addAcademicCalendar(AcademicCalendar academicCalendar) {
		getAcademicCalendars().add(academicCalendar);
		academicCalendar.setStudyType(this);

		return academicCalendar;
	}

	public AcademicCalendar removeAcademicCalendar(AcademicCalendar academicCalendar) {
		getAcademicCalendars().remove(academicCalendar);
		academicCalendar.setStudyType(null);

		return academicCalendar;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((entryDate == null) ? 0 : entryDate.hashCode());
		result = prime * result
				+ ((entryUser == null) ? 0 : entryUser.hashCode());
		result = prime * result
				+ ((fromTime == null) ? 0 : fromTime.hashCode());
		result = prime * result
				+ ((isRegular == null) ? 0 : isRegular.hashCode());
		result = prime * result
				+ ((isRestrictive == null) ? 0 : isRestrictive.hashCode());
		result = prime
				* result
				+ ((isStudyTypeFollow == null) ? 0 : isStudyTypeFollow
						.hashCode());
		result = prime * result
				+ ((moheStudyCode == null) ? 0 : moheStudyCode.hashCode());
		result = prime * result + ((osUser == null) ? 0 : osUser.hashCode());
		result = prime
				* result
				+ ((academicCalendars == null) ? 0 : academicCalendars
						.hashCode());
		result = prime * result + (int) (studyCode ^ (studyCode >>> 32));
		result = prime * result
				+ ((studyDesc == null) ? 0 : studyDesc.hashCode());
		result = prime * result
				+ ((studyDescS == null) ? 0 : studyDescS.hashCode());
		result = prime * result
				+ ((terminal == null) ? 0 : terminal.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof StudyType))
			return false;
		StudyType other = (StudyType) obj;
		if (entryDate == null) {
			if (other.entryDate != null)
				return false;
		} else if (!entryDate.equals(other.entryDate))
			return false;
		if (entryUser == null) {
			if (other.entryUser != null)
				return false;
		} else if (!entryUser.equals(other.entryUser))
			return false;
		if (fromTime == null) {
			if (other.fromTime != null)
				return false;
		} else if (!fromTime.equals(other.fromTime))
			return false;
		if (isRegular == null) {
			if (other.isRegular != null)
				return false;
		} else if (!isRegular.equals(other.isRegular))
			return false;
		if (isRestrictive == null) {
			if (other.isRestrictive != null)
				return false;
		} else if (!isRestrictive.equals(other.isRestrictive))
			return false;
		if (isStudyTypeFollow == null) {
			if (other.isStudyTypeFollow != null)
				return false;
		} else if (!isStudyTypeFollow.equals(other.isStudyTypeFollow))
			return false;
		if (moheStudyCode == null) {
			if (other.moheStudyCode != null)
				return false;
		} else if (!moheStudyCode.equals(other.moheStudyCode))
			return false;
		if (osUser == null) {
			if (other.osUser != null)
				return false;
		} else if (!osUser.equals(other.osUser))
			return false;
		if (academicCalendars == null) {
			if (other.academicCalendars != null)
				return false;
		} else if (!academicCalendars.equals(other.academicCalendars))
			return false;
		if (studyCode != other.studyCode)
			return false;
		if (studyDesc == null) {
			if (other.studyDesc != null)
				return false;
		} else if (!studyDesc.equals(other.studyDesc))
			return false;
		if (studyDescS == null) {
			if (other.studyDescS != null)
				return false;
		} else if (!studyDescS.equals(other.studyDescS))
			return false;
		if (terminal == null) {
			if (other.terminal != null)
				return false;
		} else if (!terminal.equals(other.terminal))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "StudyType [studyCode=" + studyCode + ", entryDate=" + entryDate
				+ ", entryUser=" + entryUser + ", fromTime=" + fromTime
				+ ", isRegular=" + isRegular + ", isRestrictive="
				+ isRestrictive + ", isStudyTypeFollow=" + isStudyTypeFollow
				+ ", moheStudyCode=" + moheStudyCode + ", osUser=" + osUser
				+ ", studyDesc=" + studyDesc + ", studyDescS=" + studyDescS
				+ ", terminal=" + terminal + ", academicCalendars="
				+ academicCalendars + "]";
	}

}